public final class cd extends ap
    implements k
{

    public static az a;
    public static az b;
    private cd d;
    private int e;
    private int f;
    private aj g;

    private static az a(o o1, int i1, String s, cd cd1)
    {
        az az1;
        (az1 = new az(o1, null, s)).M = (short)i1;
        if(cd1 != null)
            az1.J = cd1;
        az1.L = 11;
        return az1;
    }

    public static az a(int i1, String s)
    {
        return a(null, i1, s, null);
    }

    public cd()
    {
        this(null);
    }

    private cd(cd cd1)
    {
        super(bh.d(), 0, 0);
        d = cd1;
    }

    public final cd b(int i1, String s)
    {
        az az1 = a(bh.a("menu1"), i1, s, null);
        b(az1);
        return this;
    }

    public final cd c(int i1, String s)
    {
        cd cd1 = new cd(this);
        az az1 = a(bh.a("menu1"), i1, s, cd1);
        b(az1);
        return cd1;
    }

    public final void h()
    {
        boolean flag = ce.a(11) && !ce.a(28);
        if(d == null)
            if(flag)
                super.H.k(-30);
            else
                k(-100);
        byte byte0 = ((byte)(d != null || flag ? 0 : -100));
        int i1 = 0;
        for(int j1 = super.c; i1 < j1; i1++)
            a(i1).k(byte0);

    }

    public final cd i()
    {
        if(d != null)
            d.b(d.d != null);
        return d;
    }

    public final az c(int i1)
    {
        int j1 = 0;
        for(int k1 = super.c; j1 < k1; j1++)
        {
            az az1;
            if(((ba) (az1 = (az)a(j1))).M == i1)
                return az1;
            if(((ba) (az1)).J != null && (az1 = ((cd)((ba) (az1)).J).c(i1)) != null)
                return az1;
        }

        return null;
    }

    public final cd a(int i1, boolean flag) {
        az az1 = c(i1);
        if (az1 != null) {
            if (flag)
                az1.L = ((az1)).L | 2;
            else
                az1.L = ((az1)).L & -3;
        }
        return this;
    }

    public final cd j()
    {
        b(false);
        return this;
    }

    private void b(boolean flag) {
        int i1;
        int j1;
        i1 = 0;
        j1 = super.c;
        for (; i1 < j1; i1++) {
            az az1;
            (az1 = (az) a(i1)).L = 11;
            if (flag) {
                if (bh.e()) {
                    az1.I = bh.a(((ba) (az1)).J != null ? "submenu2.small" : "submenu1.small");
                } else {
                    az1.I = bh.a(((ba) (az1)).J != null ? "submenu2" : "submenu1");
                }
            } else {
                az1.I = bh.a(((ba) (az1)).J != null ? "menu2" : "menu1");
            }
            if (((ba) (az1)).J != null)
                ((cd) ((ba) (az1)).J).b(true);
        }
    }

    public final void b(int i1, int j1, int k1, int l1)
    {
        if(d != null || ce.a(11))
        {
            int i2 = 0;
            for(int j2 = super.c; i2 < j2; i2++)
                a(i2).k(k1);

        }
        super.b(i1, j1, k1, l1);
    }

    private void b(int i1, int j1)
    {
        e = i1;
        f = j1;
    }

    private aj k()
    {
        aj aj1;
        (aj1 = aj.a(this)).c = this;
        ca ca1 = (ca)aj1.a(0);
        if(d == null)
        {
            ca1.I = bh.a("menu");
            aj1.L |= 0x40;
        } else
        {
            ca1.I = bh.a("submenu");
            ca1.b(e, f);
        }
        aj1.a(1).I = bh.a("options.menu");
        return aj1;
    }

    public final cd a(ba ba1)
    {
        return null;
    }

    public final az b(ba ba1, int i1)
    {
        if(i1 == 3)
            return a;
        if(i1 == 2)
            return b;
        else
            return null;
    }

    public final boolean a(Object obj)
    {
        k k1;
        if((k1 = g.c) != null)
            return k1.a(obj);
        else
            return false;
    }

    public final void a(ba ba1, int i1)
    {
    }

    public final void a(aj aj1)
    {
        g = aj1;
        bh bh1 = bh.b();
        aj aj2 = k();
        if(d == null)
            synchronized(bh1)
            {
                bh1.a(aj2, false);
                int i1 = bh.d.g - super.H.K.e;
                bh1.a(1, 0, i1, bh.d.f, bh.d.g, aj2);
            }
        else
            bh1.a(aj2, true);
    }

    public final void a(boolean flag)
    {
        bh.b().b(q(), flag);
        super.H = null;
        g = null;
    }

    private void l()
    {
        cd cd1 = this;
        while(cd1 != null){
            cd1.a(false);
            cd1 = cd1.d;
        }
        bh.b().o();
    }

    private void d(int i1)
    {
        aj aj1 = q();
        int j1 = super.c;
        ba ba1;
        int k1 = (ba1 = aj1.b) != null ? d(ba1) : -1;
        for(int l1 = j1; l1 > 0; l1--)
        {
            if((k1 += i1) < 0)
                k1 = j1 - 1;
            else
            if(k1 >= j1)
                k1 = 0;
            ba ba2;
            if((ba2 = a(k1)).F())
            {
                aj1.a(ba2, 6);
                return;
            }
        }

    }

    private void a(ba ba1, boolean flag)
    {
        bh bh1 = bh.b();
        if(ba1.J != null)
        {
            cd cd1 = (cd)ba1.J;
            bk bk1 = bh.e(ba1);
            cd1.b(ce.f != 1 ? bk1.c() : ((int) (bk1.d)), bk1.e);
            cd1.a(g);
            return;
        }
        if(!flag)
        {
            aj aj1 = g;
            l();
            bh1.a(aj1.c, aj1.b, ba1.M);
        }
    }

    public final boolean a(int i1, int j1) {
        if (i1 != 2) {
            switch (j1) {
                case -7:
                    l();
                    break;
                case -6:
                case -5:
                case 10:
                    ba ba1;
                    if ((ba1 = q().b) != null)
                        a(ba1, false);
                    break;
                case -4:
                    if (ce.f != 1) {
                        ba ba2;
                        if ((ba2 = q().b) != null)
                            a(ba2, true);
                        break; /* Loop/switch isn't completed */
                    }
                    a(true);
                    break;
                case -3:
                    if (ce.f == 1) {
                        ba ba3;
                        if ((ba3 = q().b) != null)
                            a(ba3, true);
                        break; /* Loop/switch isn't completed */
                    }
                    a(true);
                    break;
                case -2:
                    d(1);
                    break;
                case -1:
                    d(-1);
                    break;

            }
        }
        return true;
    }

    public final boolean a(int i1, int j1, int k1)
    {
        if(i1 == 1)
        {
            aj aj1 = q();
            int l1 = super.c;
            for(int i2 = 0; i2 < l1; i2++)
            {
                ba ba1;
                if((ba1 = a(i2)).F() && ba1.K.a(j1, k1))
                {
                    aj1.a(ba1, 6);
                    a(ba1, false);
                    return true;
                }
            }

        }
        return false;
    }

    public final void a()
    {
    }
}